package com.zhangliuliu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhangliuliu.bean.DiseaseBean;
import com.zhangliuliu.service.DiseaseService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("disease")
public class diseaseController {
    @Resource
    private DiseaseService diseaseService;

    @RequestMapping("add")
    @ResponseBody
    public void add(DiseaseBean diseaseBean) {
        diseaseService.add(diseaseBean);
    }

    @RequestMapping("find")
    @ResponseBody
    public DiseaseBean find(int id) {
        return diseaseService.find(id);
    }
    @RequestMapping("cut")
    @ResponseBody
    public IPage<DiseaseBean> cut(@RequestParam(value = "pageNO",defaultValue = "1") int pageNo,
                                        @RequestParam(value = "pageSize",defaultValue = "4") int pageSize,
                                        @RequestParam("name") String name, @RequestParam ("harm") String harm,
                                        @RequestParam("regular") String regular ) {

        return diseaseService.cut(pageNo,pageSize,name,harm,regular);
    }
    @RequestMapping("cutByItem")
    @ResponseBody
    IPage<DiseaseBean> cutByItem(@RequestParam("pageNo") int pageNo,@RequestParam("pageSize") int pageSize,
                                 @RequestParam("name") String name, @RequestParam("disease") String disease){
        return diseaseService.cutByItem(pageNo,pageSize,name,disease);
    }



}
